package com.zx.flow.api.execute.request;

import com.zx.flow.api.util.Util;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@Schema(title = "流程-创建", description = "流程-创建")
public class FlowParamCreate extends FlowParam {

    @Schema(description = "流程配置code", example = "my_apply", requiredMode = RequiredMode.REQUIRED)
    @NotEmpty(message = "流程配置code不能为空")
    private String flowCode;

    @Schema(description = "流程标题", example = "【张三】关于XXX申请", requiredMode = RequiredMode.REQUIRED)
    @NotEmpty(message = "流程标题不能为空")
    private String title;

    @Schema(description = "申请原因", example = "需要XXXXX", requiredMode = RequiredMode.REQUIRED)
    @NotEmpty(message = "申请原因不能为空")
    private String applyReason;

    @Schema(description = "申请人账号", example = "zhangsan", requiredMode = RequiredMode.REQUIRED)
    @NotEmpty(message = "申请人账号不能为空")
    private String applyAccountCode;

    @Schema(description = "自定义流程上下文数据,支持json,map,pojo。不支持数组和ArrayList", example = "{\"type\":1, \"account\":\"zhangsan\"}", requiredMode = RequiredMode.NOT_REQUIRED)
    private String extendData;

    public FlowParamCreate(String flowCode, String title, String applyReason, String applyAccountCode,
            Object extendData) {
        this.flowCode = flowCode;
        this.title = title;
        this.applyReason = applyReason;
        this.applyAccountCode = applyAccountCode;
        this.extendData = Util.getJsonStr(extendData);
    }
}
